3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
22 * ResourceLoaderFileModule which magically loads the right skinScripts and skinStyles for every
23 * skin, using the specified OOUI theme for each.
27 class ResourceLoaderOOUIFileModule
extends ResourceLoaderFileModule
{
28 use ResourceLoaderOOUIModule
;
30 public function __construct( $options = [] ) {
31 if ( isset( $options[ 'themeScripts' ] ) ) {
32 $options['skinScripts'] = $this->getSkinSpecific( $options[ 'themeScripts' ], 'scripts' );
34 if ( isset( $options[ 'themeStyles' ] ) ) {
35 $options['skinStyles'] = $this->getSkinSpecific( $options[ 'themeStyles' ], 'styles' );
38 parent
::__construct( $options );
42 * Helper function to generate values for 'skinStyles' and 'skinScripts'.
44 * @param string $module Module to generate skinStyles/skinScripts for:
45 * 'core', 'widgets', 'toolbars', 'windows'
46 * @param string $which 'scripts' or 'styles'
49 private function getSkinSpecific( $module, $which ) {
50 $themes = self
::getSkinThemeMap();
53 array_keys( $themes ),
54 array_map( function ( $theme ) use ( $module, $which ) {
55 if ( $which === 'scripts' ) {
56 return $this->getThemeScriptsPath( $theme, $module );
58 return $this->getThemeStylesPath( $theme, $module );
60 }, array_values( $themes ) )